package gui.CustomerServiceWorker;

import java.awt.Color;
import java.awt.SystemColor;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.TitledBorder;

import control.LoginController;

import system.SystemTypes;
import system.VCP;
import javax.swing.JComboBox;
import javax.swing.JTextArea;
import javax.swing.JTextField;
/**
 * this class use  for Customer Service Resolution Center Screen
 * @author G8
 *
 */
public class ResolutionCenterScreen extends JPanel implements ActionListener{
	public JButton btnLogout;
	public JButton btnBack;
	private JTextField textField;
	/**
	 *Customer Service Resolution Center Screen  Constructor 
	 */
	public ResolutionCenterScreen(){
		super();
		initialize();
	}
	/**
	 * This method contains the view of the Panel
	 */
	private void initialize() {
		setBorder(new TitledBorder(UIManager.getBorder("TitledBorder.border"), "Resolution Center", TitledBorder.LEADING, TitledBorder.TOP, null, new Color(0, 0, 0)));
		setBackground(SystemColor.menu);
		setBounds(VCP.guiX,VCP.guiY,500,400);
		setLayout(null);
		VCP.frame.setBounds(this.getBounds());
		
		btnBack = new JButton("Back");
		btnBack.setIcon(new ImageIcon(CustomerSaveParkingScreen.class.getResource("/img/back.png")));
		btnBack.setSize(150, 30);
		btnBack.setBounds(281, 22, 102, 35);
		btnBack.addActionListener(this);
		add(btnBack);
		
		btnLogout = new JButton("Logout");
		btnLogout.setSize(150, 30);
		btnLogout.setBounds(393, 22, 78, 35);
		btnLogout.addActionListener(this);
		add(btnLogout);
		
		JLabel lblComplainant = new JLabel("Complainant:");
		lblComplainant.setBounds(69, 71, 102, 14);
		add(lblComplainant);
		
		JComboBox comboBoxComplainant = new JComboBox();
		comboBoxComplainant.setBounds(181, 68, 138, 20);
		add(comboBoxComplainant);
		
		JLabel lblComplaint = new JLabel("Complaint:");
		lblComplaint.setBounds(69, 96, 92, 14);
		add(lblComplaint);
		
		JTextArea textAreaComplaintContent = new JTextArea();
		textAreaComplaintContent.setEditable(false);
		textAreaComplaintContent.setBounds(69, 121, 365, 45);
		add(textAreaComplaintContent);
		
		JLabel lblResponse = new JLabel("Response:");
		lblResponse.setBounds(69, 177, 82, 14);
		add(lblResponse);
		
		JTextArea textAreaResponse = new JTextArea();
		textAreaResponse.setBounds(69, 202, 365, 45);
		add(textAreaResponse);
		
		JLabel lblRefund = new JLabel("Refund:");
		lblRefund.setBounds(69, 258, 82, 14);
		add(lblRefund);
		
		textField = new JTextField();
		textField.setBounds(126, 258, 86, 20);
		add(textField);
		textField.setColumns(10);
		
		JButton buttonReply = new JButton("Reply & Refund");
		buttonReply.setBounds(180, 292, 131, 35);
		add(buttonReply);
	}
	/**
	 * This method listens to the buttons on the panel
	 * @param e is the buttons the user Click
	 */
	@Override
	public void actionPerformed(ActionEvent e) {
		
		if (e.getSource() == btnBack){
			VCP.setScreen(this, VCP.prevScreen);
			VCP.prevScreen.setBounds(VCP.guiX,VCP.guiY,500,400);
			VCP.prevScreen.setLayout(null);
			VCP.frame.setBounds(VCP.prevScreen.getBounds());
		}
		if (e.getSource() == btnLogout){
			SystemTypes userToLogout = new SystemTypes(VCP.currentUser,null);
			boolean logoutRes = LoginController.LogOut(userToLogout);
			if (logoutRes)
				VCP.setGUI(0, this);
			else{
				JOptionPane.showMessageDialog(null, "Failed to logout!", "Error",
	                    JOptionPane.ERROR_MESSAGE);
			}
		}
	}
}
